8 return ''.join([random
.choice('0123456789') for i
in range(n
)])
11 return random
.randint(0, 10**(n
/ 2))
16 s2
= str(int(s1
) + ranincr(n
))
17 if len(s2
) != len(s1
): continue
19 while i
< len(s1
) and s1
[i
] == s2
[i
]:
21 while i
> 0 and random
.choice([0, 1, 1, 1]) == 0:
23 s1
, s2
= s1
[:i
] + s1
[i
:], s2
[i
:]
30 return random
.choice(['nenuco', 'roque', 'moniche', 'mifus', 'invalid'])
34 for i
in range(random
.randint(1, 20)):
35 s1
, s2
= rango(random
.randint(1, MAXLEN
))
37 tabla
.append((s1
, s2
, p
))
41 return num
+ (10 - len(num
)) * P
47 for r
in genstrs(l
- 1):
51 def enumerar(fr
, to
, pref
):
54 while fr
+ pot
<= to
and fr
% (pot
* 10) != 0:
55 yield decor(fr
/ pot
, pref
)
62 while pot
> 0: # and fr + pot <= to:
63 while fr
+ pot
<= to
and to
% (pot
* 10) != 0:
64 yield decor(fr
/ pot
, pref
)
73 for x
in map(lambda l
: l
.strip(' \t\r\n').split(' '), ls
[1:]):
74 tabla
.append((x
[0], x
[2], x
[3]))
85 return (k
- len(xx
)) * '0' + xx
#+ '...'
87 def resultado_referencia1(tabla
):
90 for start
, end
, plan
in tabla
:
91 tabla1
.append((pad(start
), pad(start
[:-len(end
)] + end
, '9'), plan
))
99 for start
, end
, plan
in tabla
:
100 if start
<= n
and n
<= end
:
103 tabla2
[n
] = 'invalid'
106 for n
in genstrs(MAXLEN
):
111 def resultado_referencia(tabla
):
113 l
= list(resultado_referencia1(tabla
))
114 l
.append((int(l
[-1][0]) + 1, 'invalid'))
119 if v0
not in [None, 'invalid']:
120 ###print int(i0), int(i), v0
121 for j
in enumerar(int(i0
), int(i
), len(i0
)):
125 g
= file('tmp.referencia', 'w')
126 g
.write('%i\n' % (len(res
),))
128 g
.write('%s %s\n' % (x
, y
,))
132 def resultado_implementacion(tabla
):
133 f
= file('tmp.in', 'w')
134 f
.write('%i\n' % (len(tabla
),))
135 for start
, end
, plan
in tabla
:
136 f
.write('%s - %s %s\n' % (start
, end
, plan
))
138 os
.system('cat tmp.in | ./main > tmp.implementacion')
139 f
= file('tmp.implementacion', 'r')
140 ls
= map(lambda x
: tuple(x
.strip(' \t\r\n').split(' ')), f
.readlines()[1:])
146 #tabla = readtabla('tmp.in')
148 l1
= resultado_referencia(tabla
)
149 l2
= resultado_implementacion(tabla
)